import json
from websocket import create_connection
from time import sleep
from threading import Thread

a=create_connection('ws://ubuntu@52.68.85.88:8082/?params=MTA4ODcwMjY2OTgxNzY0NzEwNCxYQlRVU0QsZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SjFhV1FpT2lJeE1EZzROekF5TmpZNU9ERTNOalEzTVRBMElpd2laWGh3SWpveE5UUTROVFF5TURBNExDSnliMnhsSWpveGZRLjZJMlVDQy1iclBrMEdKZnlUbXRyZDJOWF9CaDBpVVNSZTZZNlltZ09TVjg=')

i=[0]
def recv(i):
        while 1:
                data=a.recv()
                i[0]+=1
                print('这是i',i[0])
                if i[0]==5:
                        print(data)
                if i[0]==10:
                        i[0]=0

def send():
        while 1:
                sleep(10)
                a.send('ping')
                print('发送了ping')
                
if __name__=='__main__':
        work=Thread(target=recv,args=(i,))
        ping=Thread(target=send)
        work.start()
        ping.start()